﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CLEX.Service.DataContracts;

namespace CLEX.Client.Metro
{
    public interface IFacade
    {
        event Action<DatabaseData> DatabaseCreated;
        event Action<DatabaseData> DatabaseDeleted;
        event Action<DatabaseData> DatabaseUpdated;

        UserData Login(string username, string password);
        bool ChangePassword(string username, string oldPassword, string newPassword);
        List<DatabaseData> GetDatabasesByUserId(int userId);
        int CreateDatabase(int userId, string connectionString);
        void DeleteDatabase(int databaseId);
        void UpdateDatabase(DatabaseData database);
        DatabaseData GetDatabase(int databaseId);
        List<TableData> GetSchema(string connectionString);
        List<HistogramRowData> ComputeHistograms(string connectionString, QueryData queryData);

        void GoToLogin();
        void GoToHome(UserData user);
        void GoToLattice(UserData user, DatabaseData database, TableData table);

        void ShowLogout();
        void ShowDatabaseNew(UserData user);
        void ShowTableList(UserData user, DatabaseData database);
        void ShowDatabaseEdit(DatabaseData database);
        void ShowDatabaseDelete(DatabaseData database);
        void ShowChangedPassword(UserData user);
        void ShowUnexpectedError(string errorMessage, string details);

        void ShowLatticeEdit(TableData table, LatticeState state);
        void ShowHistogramDelete(LatticeState state, AggregateData aggregate);
        void ShowHistogramNew(TableData table, LatticeState state);
    }
}
